<?php
class Application_View_Helper_Widget extends Zend_View_Helper_Abstract 
{
	public function widget($module, $name, array $params = array()) 
	{
		$module  = strtolower($module);
		$name 	 = strtolower($name);
					
		$widgetClass = ucfirst($module) . '_Widgets_' . ucfirst($name) . '_Widget';
		
		if (!class_exists($widgetClass)) {
			/**
			 * TODO: Should we inform to user that the widget does not exist
			 */
			//return 'Виджет не найден';
			throw new Zend_Controller_Action_Exception('Not found widget ' . $widgetClass, 500);
		}
		
		$widget = new $widgetClass($module, $name);
		return $widget->show($params);
	}
}
